/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.vportal.portlet.vcms.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import com.vportal.portlet.vcms.model.VcmsLogger;
import com.vportal.portlet.vcms.model.VcmsLoggerModel;
import com.vportal.portlet.vcms.model.VcmsLoggerSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * The base model implementation for the VcmsLogger service. Represents a row in the &quot;VcmsLogger&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.vportal.portlet.vcms.model.VcmsLoggerModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link VcmsLoggerImpl}.
 * </p>
 *
 * @author hai
 * @see VcmsLoggerImpl
 * @see com.vportal.portlet.vcms.model.VcmsLogger
 * @see com.vportal.portlet.vcms.model.VcmsLoggerModel
 * @generated
 */
@JSON(strict = true)
public class VcmsLoggerModelImpl extends BaseModelImpl<VcmsLogger>
	implements VcmsLoggerModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a vcms logger model instance should use the {@link com.vportal.portlet.vcms.model.VcmsLogger} interface instead.
	 */
	public static final String TABLE_NAME = "VcmsLogger";
	public static final Object[][] TABLE_COLUMNS = {
			{ "loggerId", Types.VARCHAR },
			{ "groupId", Types.BIGINT },
			{ "companyId", Types.BIGINT },
			{ "createdDate", Types.TIMESTAMP },
			{ "createdByUser", Types.VARCHAR },
			{ "content", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table VcmsLogger (loggerId VARCHAR(75) not null primary key,groupId LONG,companyId LONG,createdDate DATE null,createdByUser VARCHAR(75) null,content VARCHAR(1000) null)";
	public static final String TABLE_SQL_DROP = "drop table VcmsLogger";
	public static final String ORDER_BY_JPQL = " ORDER BY vcmsLogger.createdDate DESC";
	public static final String ORDER_BY_SQL = " ORDER BY VcmsLogger.createdDate DESC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.com.vportal.portlet.vcms.model.VcmsLogger"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.com.vportal.portlet.vcms.model.VcmsLogger"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.com.vportal.portlet.vcms.model.VcmsLogger"),
			true);
	public static long CREATEDBYUSER_COLUMN_BITMASK = 1L;
	public static long CREATEDDATE_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static VcmsLogger toModel(VcmsLoggerSoap soapModel) {
		VcmsLogger model = new VcmsLoggerImpl();

		model.setLoggerId(soapModel.getLoggerId());
		model.setGroupId(soapModel.getGroupId());
		model.setCompanyId(soapModel.getCompanyId());
		model.setCreatedDate(soapModel.getCreatedDate());
		model.setCreatedByUser(soapModel.getCreatedByUser());
		model.setContent(soapModel.getContent());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<VcmsLogger> toModels(VcmsLoggerSoap[] soapModels) {
		List<VcmsLogger> models = new ArrayList<VcmsLogger>(soapModels.length);

		for (VcmsLoggerSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.com.vportal.portlet.vcms.model.VcmsLogger"));

	public VcmsLoggerModelImpl() {
	}

	public String getPrimaryKey() {
		return _loggerId;
	}

	public void setPrimaryKey(String primaryKey) {
		setLoggerId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _loggerId;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	public Class<?> getModelClass() {
		return VcmsLogger.class;
	}

	public String getModelClassName() {
		return VcmsLogger.class.getName();
	}

	@JSON
	public String getLoggerId() {
		if (_loggerId == null) {
			return StringPool.BLANK;
		}
		else {
			return _loggerId;
		}
	}

	public void setLoggerId(String loggerId) {
		_loggerId = loggerId;
	}

	@JSON
	public long getGroupId() {
		return _groupId;
	}

	public void setGroupId(long groupId) {
		_groupId = groupId;
	}

	@JSON
	public long getCompanyId() {
		return _companyId;
	}

	public void setCompanyId(long companyId) {
		_companyId = companyId;
	}

	@JSON
	public Date getCreatedDate() {
		return _createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		_columnBitmask = -1L;

		if (_originalCreatedDate == null) {
			_originalCreatedDate = _createdDate;
		}

		_createdDate = createdDate;
	}

	public Date getOriginalCreatedDate() {
		return _originalCreatedDate;
	}

	@JSON
	public String getCreatedByUser() {
		if (_createdByUser == null) {
			return StringPool.BLANK;
		}
		else {
			return _createdByUser;
		}
	}

	public void setCreatedByUser(String createdByUser) {
		_columnBitmask |= CREATEDBYUSER_COLUMN_BITMASK;

		if (_originalCreatedByUser == null) {
			_originalCreatedByUser = _createdByUser;
		}

		_createdByUser = createdByUser;
	}

	public String getOriginalCreatedByUser() {
		return GetterUtil.getString(_originalCreatedByUser);
	}

	@JSON
	public String getContent() {
		if (_content == null) {
			return StringPool.BLANK;
		}
		else {
			return _content;
		}
	}

	public void setContent(String content) {
		_content = content;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public VcmsLogger toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (VcmsLogger)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public Object clone() {
		VcmsLoggerImpl vcmsLoggerImpl = new VcmsLoggerImpl();

		vcmsLoggerImpl.setLoggerId(getLoggerId());
		vcmsLoggerImpl.setGroupId(getGroupId());
		vcmsLoggerImpl.setCompanyId(getCompanyId());
		vcmsLoggerImpl.setCreatedDate(getCreatedDate());
		vcmsLoggerImpl.setCreatedByUser(getCreatedByUser());
		vcmsLoggerImpl.setContent(getContent());

		vcmsLoggerImpl.resetOriginalValues();

		return vcmsLoggerImpl;
	}

	public int compareTo(VcmsLogger vcmsLogger) {
		int value = 0;

		value = DateUtil.compareTo(getCreatedDate(), vcmsLogger.getCreatedDate());

		value = value * -1;

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		VcmsLogger vcmsLogger = null;

		try {
			vcmsLogger = (VcmsLogger)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = vcmsLogger.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public void resetOriginalValues() {
		VcmsLoggerModelImpl vcmsLoggerModelImpl = this;

		vcmsLoggerModelImpl._originalCreatedDate = vcmsLoggerModelImpl._createdDate;

		vcmsLoggerModelImpl._originalCreatedByUser = vcmsLoggerModelImpl._createdByUser;

		vcmsLoggerModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<VcmsLogger> toCacheModel() {
		VcmsLoggerCacheModel vcmsLoggerCacheModel = new VcmsLoggerCacheModel();

		vcmsLoggerCacheModel.loggerId = getLoggerId();

		String loggerId = vcmsLoggerCacheModel.loggerId;

		if ((loggerId != null) && (loggerId.length() == 0)) {
			vcmsLoggerCacheModel.loggerId = null;
		}

		vcmsLoggerCacheModel.groupId = getGroupId();

		vcmsLoggerCacheModel.companyId = getCompanyId();

		Date createdDate = getCreatedDate();

		if (createdDate != null) {
			vcmsLoggerCacheModel.createdDate = createdDate.getTime();
		}
		else {
			vcmsLoggerCacheModel.createdDate = Long.MIN_VALUE;
		}

		vcmsLoggerCacheModel.createdByUser = getCreatedByUser();

		String createdByUser = vcmsLoggerCacheModel.createdByUser;

		if ((createdByUser != null) && (createdByUser.length() == 0)) {
			vcmsLoggerCacheModel.createdByUser = null;
		}

		vcmsLoggerCacheModel.content = getContent();

		String content = vcmsLoggerCacheModel.content;

		if ((content != null) && (content.length() == 0)) {
			vcmsLoggerCacheModel.content = null;
		}

		return vcmsLoggerCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(13);

		sb.append("{loggerId=");
		sb.append(getLoggerId());
		sb.append(", groupId=");
		sb.append(getGroupId());
		sb.append(", companyId=");
		sb.append(getCompanyId());
		sb.append(", createdDate=");
		sb.append(getCreatedDate());
		sb.append(", createdByUser=");
		sb.append(getCreatedByUser());
		sb.append(", content=");
		sb.append(getContent());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(22);

		sb.append("<model><model-name>");
		sb.append("com.vportal.portlet.vcms.model.VcmsLogger");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>loggerId</column-name><column-value><![CDATA[");
		sb.append(getLoggerId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>groupId</column-name><column-value><![CDATA[");
		sb.append(getGroupId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>companyId</column-name><column-value><![CDATA[");
		sb.append(getCompanyId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdDate</column-name><column-value><![CDATA[");
		sb.append(getCreatedDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>createdByUser</column-name><column-value><![CDATA[");
		sb.append(getCreatedByUser());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>content</column-name><column-value><![CDATA[");
		sb.append(getContent());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = VcmsLogger.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			VcmsLogger.class
		};
	private String _loggerId;
	private long _groupId;
	private long _companyId;
	private Date _createdDate;
	private Date _originalCreatedDate;
	private String _createdByUser;
	private String _originalCreatedByUser;
	private String _content;
	private long _columnBitmask;
	private VcmsLogger _escapedModelProxy;
}